package com.platform.server.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.platform.server.dao.AdvDao;
import com.platform.server.service.AdvService;
import com.platform.server.util.StringTools;

@Service
public class AdvServiceImpl implements AdvService {

	@Autowired
	private AdvDao advDao;
	
	/**
	 * 查看启动页
	 */
	@Override
	public List<Map<String, Object>> selectAdvList(String type,String id,String startTime,String endTime,String status) {
		Map<String,Object> map = new HashMap<>();
		map.put("type", type);
		if(!StringTools.isEmpty(id)){
			map.put("id", Integer.parseInt(id));
		}
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("status", status);
		return advDao.selectAdvList(map);
	}

	/**
	 * 修改图片信息
	 */
	@Override
	public int updateImageInfo(Integer id,String image_link,String position_id, String image_url, String is_ban) {
		Map<String,Object> map = new HashMap<>();
		map.put("id", id);
		map.put("image_link", image_link);
		map.put("position_id", position_id);
		map.put("image_url", image_url);
		map.put("is_ban", is_ban);
		return advDao.updateImageInfo(map);
	}

	/**
	 * 添加首页或发现轮播图
	 */
	@Override
	public int insertSlideshow(String image_link,String position_id,String type,String image_url,String is_ban) {
		Map<String, Object> map = new HashMap<>();
		map.put("image_link", image_link);
		map.put("position_id", position_id);
		map.put("type", type);
		map.put("image_url", image_url);
		map.put("is_ban", is_ban);
		return advDao.insertSlideshow(map );
		
	}

	/**
	 * 删除首页或发现轮播图
	 */
	@Override
	public int deleteSlideshow(String id) {
		return advDao.deleteSlideshow(id);
	}

}
